package com.zhuannimei.net;

import java.util.Map;

import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
import com.zhuannimei.fragment.Fragment1;
import com.zhuannimei.utility.UrlBank;
import com.zhuannimei.utility.WuLog;
import com.zhuannimei.utility.YouLog;

/**
 * 网络请求统一管理类
 * 
 * @author Jack 2013-12-4
 * 
 * 
 */
public class RequestServerData {
	private static  HttpUtils http = new HttpUtils();
	private static final String TAG = "RequestServerData";

	/**
	 * 获取商品列表的网络请求
	 * 
	 * @param params
	 * @return
	 */
	public static void productList(RequestParams params,RequestCallBack<String> callBack) {
		http.send(HttpMethod.POST, UrlBank.getProductList(), params, callBack);
	}

	/**
	 * 用户注册
	 * 
	 * @param params
	 * @return
	 */
	public static void userReg(RequestParams params,RequestCallBack<String> callBack) {
		http.send(HttpMethod.POST, UrlBank.getUserReg(), params, callBack);
	}

	/**
	 * 用户登陆
	 * 
	 * @param params
	 * @return
	 */
	public static void userLogin(RequestParams params,RequestCallBack<String> callBack) {
		http.send(HttpMethod.POST, UrlBank.getUserLogin(), params, callBack);
	}
	/**
	 * 请求排行数据
	 * @param params
	 * @return
	 */
	public static void  userRank(RequestParams  params,RequestCallBack<String> callBack){
		http.send(HttpMethod.POST,UrlBank.getUserRank(), params, callBack);
	}
	
	/**
	 * 购买商品
	 * @param params
	 * @return
	 */
	public static String buyProduct(Map<String,String>  params){
		return LpHttpReqHelper.post(UrlBank.sendBuy(), params);
	}
	
	/**
	 * 购买商品记录
	 * @param params
	 * @return
	 */
	public static String getHistorys(Map<String,String>  params){
		return LpHttpReqHelper.post(UrlBank.getHistorys(), params);
	}
	
	/**
	 * 获取推广列表
	 * @param params
	 * @return
	 */
	public static void  getAdds(RequestParams  params,RequestCallBack<String> callBack){
		http.send(HttpMethod.GET,UrlBank.getAdd(), params, callBack);
	}
	
	
	/**
	 * 推广员申请
	 * @param params
	 * @return
	 */
	public static void  getJoinUs(RequestParams  params,RequestCallBack<String> callBack){
		http.send(HttpMethod.POST,UrlBank.getJoinUs(), params, callBack);
	}

	/**
	 * 抽奖
	 * @param map2
	 * @return
	 */
	public static String getLottery(Map<String, String> map2) {
		YouLog.i(TAG, "抽奖："+UrlBank.getLottery());
		return LpHttpReqHelper.post(UrlBank.getLottery(), map2);
	}
	/**
	 * 获取一元购活动列表
	 * @param params
	 * @param callBack
	 */
	public static void getLuckList(RequestParams params,RequestCallBack<String> callBack){
		WuLog.i(TAG, "获取一元购活动列表"+UrlBank.getLuckListUrl());
		http.send(HttpMethod.POST, UrlBank.getLuckListUrl(), params, callBack);
	}
	/**
	 * 购买商品
	 * @param mParams
	 * @param requestCallBack
	 */
	public static void getProductsFromNet(RequestParams mParams,
			RequestCallBack<String> callBack) {
		YouLog.i(TAG, "购买商品："+UrlBank.getLottery());
		http.send(HttpMethod.POST, UrlBank.getProductsFromNet(), mParams, callBack);
	}
	
	/**
	 * 参与一元购
	 * @param mParams
	 * @param requestCallBack
	 */
	public static void getLuck(RequestParams mParams,
			RequestCallBack<String> callBack) {
		YouLog.i(TAG, "参与一元购"+UrlBank.getLuck());
		http.send(HttpMethod.POST, UrlBank.getLuck(), mParams, callBack);
	}
	/**
	 * 一元购参与记录 getLuckHistory
	 */
	public static void getLuckHistory(RequestParams mParams,
			RequestCallBack<String> callBack) {
		YouLog.i(TAG, "参与一元购记录"+UrlBank.getLuckHistory());
		http.send(HttpMethod.POST, UrlBank.getLuckHistory(), mParams, callBack);
	}
	/**
	 * 购买商品记录
	 */
	public static void getProductHistory(RequestParams mParams,
			RequestCallBack<String> callBack) {
		YouLog.i(TAG, "参与一元购记录"+UrlBank.getProductHistory());
		http.send(HttpMethod.POST, UrlBank.getProductHistory(), mParams, callBack);
	}
	
	/**
	 * 更新积分
	 */
	public static void updatePoint(RequestParams mParams,
			RequestCallBack<String> callBack) {
		http.send(HttpMethod.POST, UrlBank.updatePoint(), mParams, callBack);
	}

	/**
	 * 获取用户总积分
	 * @param params
	 * @param requestCallBack
	 */
	public static void getMypoint(RequestParams mParams,
			RequestCallBack<String> callBack) {
		http.send(HttpMethod.POST, UrlBank.getMypoint(), mParams, callBack);
		
	}
	
	/**
	 * 获取用户总积分
	 * @param params
	 * @param requestCallBack
	 */
	public static void getPhaseNum(RequestParams mParams,
			RequestCallBack<String> callBack) {
		http.send(HttpMethod.POST, UrlBank.getPhaseCount() ,mParams, callBack);
	}
	
	
	/**
	 * 获取参与者列表
	 * @param params
	 * @param requestCallBack
	 */
	public static void getJoinList(RequestParams mParams,
			RequestCallBack<String> callBack) {
		http.send(HttpMethod.POST, UrlBank.getJoinList() ,mParams, callBack);
	}
	
	/**
	 * 获取活动详情
	 * @param params
	 * @param requestCallBack
	 */
	public static void getLuckDetail(RequestParams mParams,
			RequestCallBack<String> callBack) {
		http.send(HttpMethod.POST, UrlBank.getLuckDetail(),mParams, callBack);
	}
	
}
